now i need to think how i am going to repopulate that dropdown list [i.e pretty much rerun that segment of php code again to update the dropdown list] when an ajax event is submitted.
i have the ajax calls sorted for the mysql updates via php, but i cant think through the logic for how i am going to update that list after these other database updates/events have occured. [the dropdown list options need to change after these updates occur]
i am using the prototypejs library
i will post relevant sections of code..
<script type="text/javascript"> function sendRequestClose() { new Ajax.Request("sendmailclose.php", { method: 'post', postBody: "tradeID="+$F("tradeID")+"&closeprice="+$F("closeprice"), onLoading: showLoading, //have to add alert onSuccess: function(transport){ var response = transport.responseText || "no response text"; alert("Success! \n\n" + response); }, onFailure: function(){ alert('NO EMAILS SENT - NO RESPONSE FROM SERVER') }, onComplete: hideLoading } ); } </script> .... <p> CLOSE TRADE : <!-- PHP --> <?php // Make a MySQL Connection mysql_connect("localhost", "ssss", "sssss")or die(mysql_error()); mysql_select_db("db")or die(mysql_error()); $result = @mysql_query("SELECT ID,open_time,pair,open_price,LS FROM log_open"); print "<select name=\"tradeID\" id=\"tradeID\">"; while ($row = mysql_fetch_assoc($result)) { $tradeID = $row['ID']; $opentime = $row['open_time']; $pair = $row['pair']; $price = $row['open_price']; if ($pair == "eu") {$price = round($price,4);} else {$price = round($price,2);} $LS = $row['LS']; print "<option value=$tradeID id=$tradeID>$tradeID $LS $pair $price $opentime";} print "</select>"; ?> price <input name="closeprice" id="closeprice" type="text" size ="7"> <input type="submit" value="CLOSE" name="submit" onClick="java script: sendRequestClose();"> </p>
I essentially need that dropdown list to be recreated by running the same php code segment after the sendRequestClose javascript function is called [i.e the database is updated].
Can anyone explain or show me how i should go about this please? i am a relative newbie at this and i am struggling to work out where i start with this.
thanks for lookin. any commentary at all is welcome, cos i am pretty stuck here.